/**
*	This module has log itens to save information about the changes occurred and can't be sent immediactly to the Castor server (synchronization methods).
*	The method genXML returns a string with the xml of the minitransaction information.
* 	These minitransactions are tiny, unitary messages which informs the server what was atomically modified from the user's workspace. 
*
*	The implemented synchronization methods are:
*
*	- NewPostIt      : triggered when a new post-it is addded somewhere;
*	- AlterPostIt    : triggered when a post-it is modified;
*	- RemovePostIt   : triggered when a post-it is deleted;
*	- NewProject     : triggered when a project is created;
*	- AlterProject   : triggered when a project is altered;
*	- RemoveProject  : triggered when a project is removed;
*	- AlterContainer : triggered when a post-it is moved from one boardStatus (to do, doing ...) to another;
*
*/

/**
*	Class: NewPostIt
*
*	@param postIt - the added post-it 
*	@param projectId - the project's id which the post-it belongs to
*	@param containerId - the container's id which the post-it belongs to
*/
function NewPostIt(postIt, containerId, projectId){

	this._newPostIt = postIt;
	this._projectId = projectId;
	this._containerId = containerId;

	if(typeof NewPostIt.prototype._initialized == "undefined"){

		NewPostIt.prototype.genXML = function(){
			var xml = new String("<newPost>");
			xml += this._newPostIt.genXML();
			xml += "<contId>" + this._containerId + "</contId>";
			xml += "<projId>" + this._projectId + "</projId>";
			xml += "</newPost>";

			return xml;
		};
		
		NewPostIt.prototype._initialized = true;	
	}
}

/**
*	Class: AlterPostIt
*
*	@param postIt - the modified post-it 
*	@param projectId - the project's id which the post-it belongs to
*/
function AlterPostIt(postIt, projectId){

	this._alteredPostIt = postIt;
	this._projectId = projectId;

	if(typeof AlterPostIt.prototype._initialized == "undefined"){

		AlterPostIt.prototype.genXML = function(){
			var xml = new String("<alterPost>");
			xml += "<projId>" + this._projectId + "</projId>";
			xml += this._alteredPostIt.genXML();
			xml += "</alter-post>";

			return xml;
		};
		
		AlterPostIt.prototype._initialized = true;
	}

}

/**
*	Class: RemovePostIt
*
*	@param postId - the id from the removed post-it
*	@param projectId - the project's id which the post-it belongs
*/
function RemovePostIt(postId, projectId){

	this._remPostId = postId;
	this._projectId = projectId;

	if(typeof RemovePostIt.prototype._initialized == "undefined"){

		RemovePostIt.prototype.genXML = function(){
			var xml = new String("<remove-post>");
			xml += "<project-id>" + this._projectId + "</project-id>";
			xml += "<post-id>" + this._remPostId + "</post-id>";
			xml += "</remove-post>";

			return xml;
		};
		
		RemovePostIt.prototype._initialized = true;	
	}

}

/**
*	Class: NewProject
*
*	@param project - the created project 
*/
function NewProject(project){

	this._newProject = project;

	if(typeof NewProject.prototype._initialized == "undefined"){

		NewProject.prototype.genXML = function(){
			var xml = new String("<new-project>");
			xml += this._newProject.genXML();
			xml += "</new-project>";

			return xml;
		};
		
		NewProject.prototype._initialized = true;	
	}
}

/**
*	Class: AlterProject
*
*	@param project - the modified project 
*/
function AlterProject(project){

	this._alterProject = project;

	if(typeof AlterProject.prototype._initialized == "undefined"){

		AlterProject.prototype.genXML = function(){
			var xml = new String("<alter-project>");
			xml += this._alterProject.genXML();
			xml += "</alter-project>";

			return xml;
		};
		
		AlterProject.prototype._initialized = true;	
	}
}

/**
*	Class: RemoveProject
*
*	@param projectId - the id from the removed project
*/
function RemoveProject(projectId){

	this._remProjectId = projectId;

	if(typeof RemoveProject.prototype._initialized == "undefined"){

		RemoveProject.prototype.genXML = function() {
			var xml = new String("<alter-project>");
			xml += this._remProjectId;
			xml += "</alterProject>";

			return xml;
		};
		
		RemoveProject.prototype._initialized = true;	
	}
}

/**
*	Class: AlterContainer
*
*	@param postId - id from the modified post-it
*	@param projectId - id from the project which the moved post-it belongs to
*	@param oldContainer - id from the container which the post-it was extracted
*	@param newContainer - id from the container which the post-it was moved to
*/
function AlterContainer(postId, projectId, oldContainer, newContainer){

	this._postId = postId;
	this._projectId = projectId;
	this._oldContainer = oldContainer;
	this._newContainer = newContainer;

	if(typeof AlterContainer.prototype._initialized == "undefined"){

		AlterContainer.prototype.genXML = function(){
			var xml = new String("<alterCont>");
			
			xml += "<projId>" + this._projectId + "</projId>";
			xml += "<postId>" + this._postId + "</postId>";
			
			xml += "<oldCont>" + this._oldContainer + "</oldCont>";
			xml += "<newCont>" + this._newContainer + "</newCont>";
			
			xml += "</alterCont>";

			return xml;
		};
		
		AlterContainer.prototype._initialized = true;	
	}

}

